Placement of canavs

Hi,

Say I have a dialog box with a label saying "Enter Name" and a field underneath.
I want to have a little red box which pops up next to the label if the user has tried to submit the form without entering text in the field.

I have managed to use a canvas to create a small red box which shows following error checking, but cannot get it placed next to (on the right or left of) the label.

I have tried using beside(DB) and opposite(DB), as well as "complex" constraints by setting the left side of the canvas to be spaced from the label but I just cannot get it to work.

The canvas is initially hidden, then shown if the form is submitted incorrectly.

Thanks,
Simon
SystemAdmin - Thu Jul 29 06:32:57 EDT 2010

Re: Placement of canavs
Mathias Mamsch - Thu Jul 29 07:48:58 EDT 2010

Usually you would do it like this:
 

DB diag = centered "..."
   
   DBE canv = canvas (...) // specify the width here ...
   
   canv->"top"->"form"
   canv->"left"->"form"
   canv->"right"->"unattached"
 
   DBE dbeLab = label (...) 
   dbeLab->"top"->"form"
   dbeLab->"left"->"spaced"->canv
   dbeLab->"right"->"form"
 
   show diag

 


Something like this should do the trick ...

 

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

Re: Placement of canavs
SystemAdmin - Thu Jul 29 08:14:10 EDT 2010

Mathias Mamsch - Thu Jul 29 07:48:58 EDT 2010

Usually you would do it like this:
 

DB diag = centered "..."
   
   DBE canv = canvas (...) // specify the width here ...
   
   canv->"top"->"form"
   canv->"left"->"form"
   canv->"right"->"unattached"
 
   DBE dbeLab = label (...) 
   dbeLab->"top"->"form"
   dbeLab->"left"->"spaced"->canv
   dbeLab->"right"->"form"
 
   show diag

 


Something like this should do the trick ...

 

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

Hi Mathias,

Thanks for the reply. For some reason, when I do it the way you say, I get an error with a diagnostic log when I try to realize the DB.

However, when I put the canvas after the label it works fine:
 

DB diag = centered "..."
   
   DBE dbeLab = label (...) 
   dbeLab->"top"->"form"
 
   DBE canv = canvas (...) // specify the width here ...
   canv->"top"->"form"
   canv->"left"->"spaced"->dbeLab
   canv->"right"->"unattached"
 
   show diag

 


The only issue I have with it now, and this is something I've come across before, the elemenets are not actually lined up! Even if I align the two tops of the elements, the middle of the canvas is aligned with what appears to the top of the text. Is there a way of getting around this?

Thanks,
Simon

 

Re: Placement of canavs
SystemAdmin - Thu Jul 29 08:23:22 EDT 2010

Mathias Mamsch - Thu Jul 29 07:48:58 EDT 2010

Usually you would do it like this:
 

DB diag = centered "..."
   
   DBE canv = canvas (...) // specify the width here ...
   
   canv->"top"->"form"
   canv->"left"->"form"
   canv->"right"->"unattached"
 
   DBE dbeLab = label (...) 
   dbeLab->"top"->"form"
   dbeLab->"left"->"spaced"->canv
   dbeLab->"right"->"form"
 
   show diag

 


Something like this should do the trick ...

 

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

Sorry - my alignment is not correct there. It should be:

DB diag = centered "..."
   
   DBE dbeLab = label (...) 
   dbeLab->"top"->"form"
 
   DBE canv = canvas (...) // specify the width here ...
   canv->"top"->"aligned"->dbeLab
   canv->"left"->"flush"->dbeLab
   canv->"right"->"unattached"
 
   show diag

Re: Placement of canavs
Mathias Mamsch - Thu Jul 29 08:32:19 EDT 2010

SystemAdmin - Thu Jul 29 08:14:10 EDT 2010

Hi Mathias,

Thanks for the reply. For some reason, when I do it the way you say, I get an error with a diagnostic log when I try to realize the DB.

However, when I put the canvas after the label it works fine:
 

DB diag = centered "..."
   
   DBE dbeLab = label (...) 
   dbeLab->"top"->"form"
 
   DBE canv = canvas (...) // specify the width here ...
   canv->"top"->"form"
   canv->"left"->"spaced"->dbeLab
   canv->"right"->"unattached"
 
   show diag

 


The only issue I have with it now, and this is something I've come across before, the elemenets are not actually lined up! Even if I align the two tops of the elements, the middle of the canvas is aligned with what appears to the top of the text. Is there a way of getting around this?

Thanks,
Simon

 

I think the errors you are getting come from somewhere else in your code. The below works for me. Regards, Mathias
 

void repaint(DBE graph) { 
    background(graph, logicalMediumIndicatorColor) 
        color(graph, logicalHighIndicatorColor) 
        ellipse(graph, 20, 20, 75, 75) 
        color(graph, logicalMediumIndicatorColor) 
        ellipse(graph, 40, 40, 5, 5) 
        ellipse(graph, 70, 40, 5,5) 
        ellipse(graph, 48, 65, 20,20) 
} // repaint 
 
 
DB diag = centered "CanvTest"
   
   DBE canv = canvas(diag , 125, 125, repaint)
   
   canv->"top"->"form"
   canv->"left"->"form"
   canv->"right"->"unattached"
   canv->"bottom"->"form"
 
   DBE dbeLab = label (diag, "This works perfectly") 
   dbeLab->"top"->"form"
   dbeLab->"left"->"spaced"->canv
   dbeLab->"right"->"form"
 
   show diag

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

Re: Placement of canavs
SystemAdmin - Thu Jul 29 08:43:18 EDT 2010

Mathias Mamsch - Thu Jul 29 08:32:19 EDT 2010

I think the errors you are getting come from somewhere else in your code. The below works for me. Regards, Mathias
 

void repaint(DBE graph) { 
    background(graph, logicalMediumIndicatorColor) 
        color(graph, logicalHighIndicatorColor) 
        ellipse(graph, 20, 20, 75, 75) 
        color(graph, logicalMediumIndicatorColor) 
        ellipse(graph, 40, 40, 5, 5) 
        ellipse(graph, 70, 40, 5,5) 
        ellipse(graph, 48, 65, 20,20) 
} // repaint 
 
 
DB diag = centered "CanvTest"
   
   DBE canv = canvas(diag , 125, 125, repaint)
   
   canv->"top"->"form"
   canv->"left"->"form"
   canv->"right"->"unattached"
   canv->"bottom"->"form"
 
   DBE dbeLab = label (diag, "This works perfectly") 
   dbeLab->"top"->"form"
   dbeLab->"left"->"spaced"->canv
   dbeLab->"right"->"form"
 
   show diag

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

I thought it might have been incompatibility with the rest of the code, but worth checking.

I've also fixed my problem of the slight mis-alignment by putting in a 'spacer' canvas. I'm afraid I had to get rid of your face thought - the box is too small!
 

DB diag = centered "CanvTest"
   
   DBE spacer = canvas(diag, 5, 5, repaint)   
   DBE canv = canvas(diag , 20, 20, repaint)
   
   spacer->"top"->"form"
   spacer->"left"->"form"
   spacer->"right"->"unattached"
 
   canv->"top"->"flush"->spacer
   canv->"left"->"form"
   canv->"right"->"unattached"
   canv->"bottom"->"form"
 
   DBE dbeLab = label (diag, "This works perfectly") 
   dbeLab->"top"->"form"
   dbeLab->"left"->"flush"->canv
   dbeLab->"right"->"form"
 
   show diag

Re: Placement of canavs
SystemAdmin - Thu Jul 29 08:45:08 EDT 2010

Mathias Mamsch - Thu Jul 29 08:32:19 EDT 2010

I think the errors you are getting come from somewhere else in your code. The below works for me. Regards, Mathias
 

void repaint(DBE graph) { 
    background(graph, logicalMediumIndicatorColor) 
        color(graph, logicalHighIndicatorColor) 
        ellipse(graph, 20, 20, 75, 75) 
        color(graph, logicalMediumIndicatorColor) 
        ellipse(graph, 40, 40, 5, 5) 
        ellipse(graph, 70, 40, 5,5) 
        ellipse(graph, 48, 65, 20,20) 
} // repaint 
 
 
DB diag = centered "CanvTest"
   
   DBE canv = canvas(diag , 125, 125, repaint)
   
   canv->"top"->"form"
   canv->"left"->"form"
   canv->"right"->"unattached"
   canv->"bottom"->"form"
 
   DBE dbeLab = label (diag, "This works perfectly") 
   dbeLab->"top"->"form"
   dbeLab->"left"->"spaced"->canv
   dbeLab->"right"->"form"
 
   show diag

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

I meant face "though"...haven't figured out how to edit posts yet!

Thanks,
Simon